package com.xxzb.pack0720;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) throws Exception{
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您想要查询的出版社名称：");
        String pubname=sc.next();
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql:///gaofeng2207?userSSL=false";
        String username="root";
        String password="1234";
        Connection conn= DriverManager.getConnection(url,username,password);
        String sql="select count(bookid) from gaofeng2207.pubinfo p,gaofeng2207.publisher pub where p.pubid=pub.pubid and pubname=? group by p.pubid";
        PreparedStatement ps=conn.prepareStatement(sql);
        ps.setString(1,pubname);
        ResultSet rs = ps.executeQuery();
        while (rs.next()){
             int count = rs.getInt(1);
            System.out.println(pubname+"出版图书数量是："+count);
       }



    }
}
